import * as types from '../mutation-types'
import ajax from '../../service'
// initial state
// shape: [{ id, quantity }]
export const state = {
  info:{
    age: 0,
    name: 'Sean'
  }
}

// getters
export const getters = {
  age: state => state.info.age,
  name: state => state.info.name
}

// actions
export const actions = {
  userLogin ({ commit, state }, info) {
    ajax.login(info).then((data)=>{
      commit(types.USER_INFO_SAVE,data)
    })
  }
}

// mutations
export const mutations = {
  [types.USER_INFO_SAVE] (state, data) {
    state.info = data

  },
}
